package service

import dao._
import javax.inject.Inject
import play.api.libs.json.Json

import scala.concurrent.ExecutionContext.Implicits.global
import implicits.Implicits._
import tool.Pojo.AdvancedFilterData


/**
 * Created by yz on 4/6/2020
 */
class JunctionService @Inject()(junctionDao: JunctionDao)(
  implicit val queryJunctionDao: QueryJunctionDao,
  implicit val queryFsJunctionDao: QueryFsJunctionDao,
  implicit val queryLsJunctionDao: QueryLsJunctionDao,
) {

  def getAllChr = {
    junctionDao.selectAllLocation.map { locations =>
      val distChrs = locations.map(_.split(":")(0)).distinct.toList
      val chrsWithNumber = distChrs.filter { chr =>
        chr.replaceAll("chr", "").isDouble
      }.sortBy { chr =>
        chr.replaceAll("chr", "").toDouble
      }
      val otherChrs = distChrs.filterNot { chr =>
        chrsWithNumber.contains(chr)
      }.sorted
      chrsWithNumber ::: otherChrs
    }
  }

  //  def selectAllGeneSymbols(data:AdvancedFilterData)={
  //    junctionDao.selectAllGeneSymbols(data).map
  //
  //  }

}
